/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    height: 100vh;
    overflow: hidden;
}

/* Main container - responsive height based on context */
.main-container {
    width: 100%;
    height: 450px; /* Default iframe height */
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 15px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

/* Detect if running in full browser tab */
@media screen and (min-height: 600px) {
    .main-container {
        height: 90vh;
    }
}

/* Control Panel Styles */
.control-panel {
    background: #ffffff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    overflow-y: auto;
}

.control-panel h3 {
    color: #1976d2;
    margin-bottom: 20px;
    font-size: 1.2em;
    text-align: center;
    border-bottom: 2px solid #e3f2fd;
    padding-bottom: 10px;
}

.control-group {
    margin-bottom: 20px;
}

.control-group label {
    display: block;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
    font-size: 0.9em;
    cursor: help;
}

.slider-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.slider {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: #e0e0e0;
    outline: none;
    -webkit-appearance: none;
    transition: all 0.3s ease;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #1976d2;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

.slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    background: #1565c0;
}

.slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #1976d2;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.slider-container span {
    min-width: 35px;
    text-align: center;
    font-weight: bold;
    color: #1976d2;
    background: #e3f2fd;
    padding: 4px 8px;
    border-radius: 4px;
}

/* Button Styles */
.button-group {
    display: flex;
    gap: 8px;
    margin-top: 20px;
}

.action-btn {
    flex: 1;
    padding: 12px 8px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.85em;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    min-height: 44px; /* Touch-friendly minimum */
}

.start-btn {
    background: #4caf50;
    color: white;
}

.start-btn:hover {
    background: #45a049;
    transform: translateY(-2px);
}

.pause-btn {
    background: #ff9800;
    color: white;
}

.pause-btn:hover {
    background: #f57c00;
    transform: translateY(-2px);
}

.reset-btn {
    background: #f44336;
    color: white;
}

.reset-btn:hover {
    background: #d32f2f;
    transform: translateY(-2px);
}

.action-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Results Panel Styles */
.results-panel {
    background: #ffffff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    overflow-y: auto;
}

.results-panel h3 {
    color: #1976d2;
    margin-bottom: 20px;
    font-size: 1.2em;
    text-align: center;
    border-bottom: 2px solid #e3f2fd;
    padding-bottom: 10px;
}

/* Progress Bar Indicators */
.indicator-group {
    margin-bottom: 20px;
}

.indicator {
    margin-bottom: 15px;
    cursor: help;
}

.indicator label {
    display: block;
    font-weight: 600;
    color: #333;
    margin-bottom: 6px;
    font-size: 0.9em;
}

.progress-bar {
    position: relative;
    width: 100%;
    height: 20px;
    background: #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.progress-fill {
    height: 100%;
    border-radius: 10px;
    transition: all 0.8s ease;
    position: relative;
}

.progress-fill.good {
    background: linear-gradient(90deg, #4caf50, #66bb6a);
}

.progress-fill.warning {
    background: linear-gradient(90deg, #ff9800, #ffb74d);
}

.progress-fill.danger {
    background: linear-gradient(90deg, #f44336, #ef5350);
}

.progress-bar span {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-weight: bold;
    color: #333;
    font-size: 0.8em;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
}

/* Ecosystem Visualization */
.ecosystem-display {
    margin-bottom: 20px;
    cursor: help;
}

.ecosystem-display h4 {
    color: #1976d2;
    margin-bottom: 10px;
    font-size: 1em;
    text-align: center;
}

#ecosystem-canvas {
    width: 100%;
    height: 120px;
    background: linear-gradient(to bottom, #87ceeb 0%, #4682b4 100%);
    border-radius: 8px;
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.2);
}

.water-layer {
    width: 100%;
    height: 100%;
    position: relative;
}

/* Marine life containers for positioning labels with elements */
.marine-life-container, .pollution-container {
    position: absolute;
}

.fish, .turtle {
    position: absolute;
    font-size: 24px;
    animation: swim 4s infinite linear;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.plastic-particle {
    position: absolute;
    font-size: 8px;
    color: #333;
    animation: float 3s infinite ease-in-out;
    opacity: 0.7;
}

/* Labels for ecosystem elements */
.label {
    position: absolute;
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: bold;
    border: 1px solid #ccc;
    white-space: nowrap;
    z-index: 10;
    pointer-events: none;
}

.fish-label, .turtle-label {
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
}

.plastic-label {
    top: -18px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 200, 200, 0.9);
    border-color: #f44336;
}

@keyframes swim {
    0% { transform: translateX(-30px); }
    100% { transform: translateX(calc(100vw + 30px)); }
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
}

/* Positioning for marine life containers */
.marine-life-container:nth-child(1) { top: 20%; left: 0; animation: swim 6s infinite linear; animation-delay: 0s; }
.marine-life-container:nth-child(2) { top: 50%; left: 0; animation: swim 5s infinite linear; animation-delay: 2s; }
.marine-life-container:nth-child(3) { top: 70%; left: 0; animation: swim 7s infinite linear; animation-delay: 4s; }
.marine-life-container:nth-child(4) { top: 80%; left: 0; animation: swim 8s infinite linear; animation-delay: 1s; }

.pollution-container:nth-child(5) { top: 30%; left: 20%; animation: float 3s infinite ease-in-out; animation-delay: 0.5s; }
.pollution-container:nth-child(6) { top: 60%; left: 70%; animation: float 3s infinite ease-in-out; animation-delay: 1.5s; }

/* Individual fish positioning within containers */
#fish1, #fish2, #fish3, #turtle1 { position: relative; top: 0; left: 0; }
#plastic1, #plastic2 { position: relative; top: 0; left: 0; }

/* Ecosystem Legend */
.ecosystem-legend {
    margin-top: 15px;
    background: #f8f9fa;
    border-radius: 6px;
    padding: 12px;
    border: 1px solid #e9ecef;
}

.ecosystem-legend h5 {
    color: #495057;
    margin-bottom: 8px;
    font-size: 0.9em;
    font-weight: 600;
}

.legend-items {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.legend-icon {
    font-size: 16px;
    min-width: 40px;
}

.legend-text {
    font-size: 0.8em;
    color: #495057;
}

/* Feedback Panel */
.feedback-panel {
    margin-top: 15px;
}

.feedback {
    padding: 12px;
    border-radius: 8px;
    font-weight: 500;
    text-align: center;
    transition: all 0.5s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.feedback.good {
    background: #e8f5e8;
    color: #2e7d32;
    border-left: 4px solid #4caf50;
}

.feedback.warning {
    background: #fff3e0;
    color: #ef6c00;
    border-left: 4px solid #ff9800;
}

.feedback.danger {
    background: #ffebee;
    color: #c62828;
    border-left: 4px solid #f44336;
}

.feedback.neutral {
    background: #e3f2fd;
    color: #1976d2;
    border-left: 4px solid #2196f3;
}

/* Tooltip Styles */
.tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.8em;
    pointer-events: none;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
    max-width: 200px;
    text-align: center;
}

.tooltip.show {
    opacity: 1;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .main-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
        gap: 10px;
        padding: 10px;
    }
    
    .control-panel, .results-panel {
        padding: 15px;
    }
    
    .button-group {
        flex-direction: column;
        gap: 10px;
    }
    
    .action-btn {
        min-height: 48px; /* Larger touch targets on mobile */
    }
    
    #ecosystem-canvas {
        height: 100px;
    }
    
    .fish, .turtle {
        font-size: 20px;
    }
    
    .label {
        font-size: 9px;
        padding: 1px 4px;
    }
    
    .legend-items {
        gap: 4px;
    }
    
    .legend-text {
        font-size: 0.75em;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .progress-fill.good {
        background: #008000;
    }
    
    .progress-fill.warning {
        background: #ff8c00;
    }
    
    .progress-fill.danger {
        background: #dc143c;
    }
    
    .label {
        background: white;
        border-color: #000;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .fish, .turtle, .plastic-particle, .marine-life-container, .pollution-container {
        animation: none;
    }
    
    .progress-fill, .feedback, .action-btn {
        transition: none;
    }
}